<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>1、盒子水平居中</title>
    <style>
        .box1 {
            width: 200px;
            height: 200px;
            border: 1px solid #000;
            margin: 200px auto;
        }
        .parent{
            width: 100px;
            height: 100px;
            position: relative;
            margin: 0 auto;
        }
        .box2 {
            width: 100px;
            height: 100px;
            border: 1px solid red;
            position: absolute;           

        }
    </style>
</head>
<body>
    <div class="box1"></div>
    <div class="parent">
        <div class="box2"></div>
    </div>
    
</body>
</html>